<template>
  <div class="dialog">
    <el-dialog :model-value="showDialog" :title="title" width="1074px">
      <div class="containner">
        <div class="powerLeft">
          <div class="powerPint">
            <iframe
              v-if="detailData.file"
              :src="
                'https://view.officeapps.live.com/op/view.aspx?src=' +
                encodeURIComponent(detailData.file)
              "
              width="100%"
              height="600px"
              frameborder="0"
            >
            </iframe>
          </div>
        </div>
        <div class="powerRight">
          <div class="title">{{ detailData.name }}</div>
          <div class="power_box">
            <div class="clockLeft">
              <el-icon class="icon" :size="20">
                <Clock />
              </el-icon>
              {{ detailData.create_time }}
            </div>
            <div class="mRight">{{ detailData.fileSize }}</div>
          </div>
          <div v-if="detailData.class" class="infro-tag">
            <!-- 使用 v-for 循环数组中的每个元素 -->
            <div
              v-for="(course, index) in detailData.class"
              :key="index"
              class="tags"
            >
              {{ course }}
            </div>
          </div>
          <div class="Primary" @click="down">下载</div>
          <div v-if="detailData.video" class="video">
            <p>视频讲解:</p>
            <a class="href" :href="detailData.video"></a>
          </div>
          <div class="video">
            <p>支援描述:</p>
            <p class="txt">{{ detailData.blurb }}</p>
          </div>
        </div>
        <div class="icon" @click="CloseBold">
          <el-icon :size="20">
            <Close />
          </el-icon>
        </div>
      </div>
    </el-dialog>
  </div>
</template>
<script setup>
const emit = defineEmits(['close', 'downFile']);
const props = defineProps({
  showDialog: {
    type: Boolean,
    default: false,
  },
  detailData: {
    type: Object,
    default: () => {},
  },
  title: {
    type: String,
    default: '',
  },
});
const CloseBold = () => {
  emit('close', props.showDialog);
};
const down = () => {
  emit('downFile', props.detailData);
};
</script>
<style scoped lang="scss">
.containner {
  display: flex;
  justify-content: space-between;

  .powerLeft {
    width: 700px;
    background: #fff;
    margin-right: 20px;
    border-radius: 5px;
    min-height: 600px;
    .powerPint {
      padding: 20px;
      width: 100%;
      height: 100%;
    }
    iframe {
      height: 100%;
    }
  }

  .powerRight {
    padding: 20px;
    width: 300px;
    border-radius: 5px;
    background: #fff;
    margin-right: 20px;
    border-radius: 4px;
    overflow: hidden;

    // padding: 20px;
    .title {
      font-size: 18px;
      font-weight: 600;
      color: rgba(0, 0, 0, 0.85);
      line-height: 24px;
      margin-bottom: 17px;
    }

    .power_box {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .clockLeft {
        display: flex;
        align-items: center;

        .icon {
          color: #000;
          margin-right: 5px;
        }
      }
    }

    .infro-tag {
      display: flex;

      .tags {
        font-size: 12px;
        font-weight: 400;
        color: #666;
        padding: 6px 10px;
        background: #f5f5f5;
        border-radius: 4px;
        margin-top: 12px;
        margin-right: 10px;
        display: inline-block;
      }
    }

    .Primary {
      background-color: #165dff;
      margin: 20px 0;
      color: #fff;
      text-align: center;
      padding: 10px;
      border-radius: 5px;
      cursor: pointer;
    }

    .video {
      margin-bottom: 15px;

      .href {
        color: #165dff;
        margin-top: 15px;
        display: inline-block;
      }

      .txt {
        color: #666;
        line-height: 20px;
        margin-top: 10px;
      }
    }
  }

  .icon {
    width: 20px;
    height: 20px;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
  }
}
</style>
<style lang="scss">
.dialog {
  .el-dialog__header {
    border: none !important;
    width: 100%;
    display: none;
  }

  .el-dialog {
    background: transparent !important;
  }

  .el-dialog__close {
    color: #fff;
  }

  .el-dialog__title {
    display: none;
  }
}
</style>
